<?php

namespace App\Http\Controllers\Home;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Pay;
use SimpleSoftwareIO\QrCode\Facades\QrCode;
use Auth;
use App\Models\Order;

//use Endroid\QrCode\QrCode;
class PayController extends Controller
{
	
    public function index(Request $request, $order_id) {

        $order = Auth::user()->orders()->unpaid()->findOrFail($order_id);
       // dd($order);
        $orderInfo = [
            'out_trade_no' => $order->order_number,
            'total_fee' => intval($order->order_total_price * 100), // **单位：分**
            'body' => '支付'.$order->order_total_price.'元',
        ];

    	$pay = Pay::wechat()->scan($orderInfo);
        $qrpicture = QrCode::size(250)->generate($pay['code_url']);
        return view('home.showcode.index', ['qrcode' => $qrpicture]);
    }


}
